<?php

class Core_Controller_Action extends Zend_Controller_Action
{
	static $_instance;
	public static function getInstance()
	{
		return self::$_instance;
	}
	
	public function init() 
	{
		if(null === self::$_instance)
			self::$_instance = $this;
	}
	
	public function widget($widget)
	{
		return Core_Widget::getWidget($widget);	
	}

	public function url($url, $urlOptions = array(), $reset = false, $encode = false)
	{
		return Core_Helper_Url::url($url, $urlOptions, $reset, $encode);
	}
	
	public function redirector($url, $urlOptions = array(), $reset = false, $encode = false)
	{
		return $this->getHelper('redirector')->url($url, $urlOptions, $reset, $encode);
	}
	
	public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array())
	{
		parent::__construct($request, $response, $invokeArgs);
		$this->view->addBasePath(Core_Templates::getInstance()->getPath('_/'.$request->getParam('module')));
	}

	/*
	public function initView()
	{
		$template 	= Core_Templates::getInstance();
		
		$this->view = parent::initView();
		print_r($this->view);
		die();
		//		$this->view->addBasePath($this->template->getPath('_/'.$param['module'].'/'.$param['controller']));

		//$this->view->addBasePath($template->getPath('_/'.$path));
	}
	*/
	
	//$this->getHelper('redirector')->gotoRoute($options, $route, $reset, $encode);
	//$this->getHelper('url')->url($options, $route, $reset, $encode);
	//$this->getHelper('viewRenderer')->direct($view);
}